#include "RenderState.h"

RenderState::RenderState(void)
{
}

RenderState::RenderState( RenderState* previous, Ray* r, bool diffuse, bool specular )
{
	this->r = r;
	v = new Vertex();
	ng = new Vector3();
	object = 0;
	diffuseDepth = (previous == 0) ? 0 : previous->diffuseDepth;
	if (diffuse)
		diffuseDepth++;
	specularDepth = (previous == 0) ? 0 : previous->specularDepth;
	if (specular)
		specularDepth++;
	finalGather = false;
}

RenderState::RenderState( Ray* r )
{
	RenderState(0, r, false, false);
}
RenderState::~RenderState(void)
{
}

void RenderState::setFinalGather( bool finalGather )
{
	this->finalGather = finalGather;
}

bool RenderState::isFinalGather()
{
	return finalGather;
}

void RenderState::setIntersection( Intersectable* object, double hitT, double hitU, double hitV )
{
	this->object = object;
	this->hitT = hitT;
	this->hitU = hitU;
	this->hitV = hitV;
}

bool RenderState::hit()
{
	return object != 0;
}

int RenderState::getDepth()
{
	return diffuseDepth + specularDepth;
}

int RenderState::getDiffuseDepth()
{
	return diffuseDepth;
}

int RenderState::getSpecularDepth()
{
	return specularDepth;
}

double RenderState::getU()
{
	return hitU;
}

double RenderState::getV()
{
	return hitV;
}

double RenderState::getT()
{
	return hitT;
}

Vertex* RenderState::getVertex()
{
	return v;
}

Vector3* RenderState::getGeoNormal()
{
	return ng;
}

Intersectable* RenderState::getObject()
{
	return object;
}

Ray* RenderState::getRay()
{
	return r;
}